// pages/thing/thing.js
Page({
  data: {
    hidden:false,
    show:'',
    wshow:'',
    ad: ['../img/detail.jpg', '../img/detail.jpg', '../img/detail.jpg'],
    name:'招牌大分量蛋炒饭商家供应设置不起屏',
    price:'22.00',
    now:'15.00',
    sold:0,
    all: [{ sums: 100, name: '全部' }, { sums: 0, name: '新品' },{ sums: 0, name: '促销' }],
    allthing:'../serve/serve',
    toshop:'../serve/serve',
    gall:[],
    sums:1,
    much:'',
    sumary:'15.00'
  },
  onReachBottom: function () {
    var that=this;
    if(this.data.gall.length==0){ 
      setTimeout(function(){
        var data = that.data.gall;
        data.push('../img/detail.jpg', '../img/detail.jpg');
        that.setData({
          gall: data,
          hidden:true
        });
      },1000)
    }
  },
  submit:function(){
    wx.navigateTo({
      url: '../deals/deals',
    })
  },
  less: function (e) {
    var that = this;
    let val = this.data.sums;
    if (val > 1) {
      that.setData({
        sums: val - 1
      });
      that.total();
    }
  },
  more: function () {
    let val = this.data.sums;
    this.setData({
       sums: val + 1
    });
    this.total();
  },
  total: function () {
    var price=0;
    var price = this.data.now * this.data.sums;
    price= price.toFixed(2);
    this.setData({ sumary: price });
  },
  input:function(e){
    this.setData({
      sums: parseInt(e.detail.value)
    });
    this.total();
  },
  close:function(){
    this.setData({
      show: ''
    });
  },
  open: function () {
    this.setData({
      show: 'active'
    });
  },
  ok: function () {
    this.close();
    this.setData({
      much: 'X'+this.data.sums
    });
  },
  showopen: function () {
    this.setData({
      wshow: 'active'
    })
  },
  showclose: function () {
    this.setData({
      wshow: ''
    })
  },
  onShareAppMessage: function () {
    return { title: '推荐一个不错的视频直播平台', path: '/page/user?id=123' }
  }, 
  onLoad: function (options) {
  
  },
  onReady: function () {
  
  }
})